import { useState, useEffect } from 'react'
import { AliveScope } from 'react-activation'
import MainPage from './main-page'
import SecondPage from './second-page'
import LoginPage from './login-page'
import NoAuthPage from './system-page/no-auth-page'
import NotFoundPage from './system-page/not-found-page'
import styles from './index.module.less'

const Layout = (props: any) => {

  // const [layoutApply, setLayoutApply] = useState<LayoutType>('mainPage')
  const { layoutApply } = props

  /**
   * 检查用户权限
   */
  const checkUserAuth = () => {

  }

  const renderLayout = () => {
    switch (layoutApply) {
      case 'mainPage':
        return <MainPage />
      case 'secondPage':
        return <SecondPage />
      case 'loginPage':
        return <LoginPage />
      case 'noAuthPage':
        return <NoAuthPage />
      case 'notFoundPage':
        return <NotFoundPage />
      default:
        return <MainPage />
    }
  }

  return <div className={styles.Layout}>
    <AliveScope>
      {renderLayout()}
    </AliveScope>
  </div>
}

export default Layout
